package com.wlw.layoutmanager.activity;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wlw.layoutmanager.R;

import me.imid.swipebacklayout.lib.app.SwipeBackActivity;

public class SkidRight2Activity extends SwipeBackActivity {
    private ImageView mImgBg;
    private ImageView mImgGif;
    private TextView mTvTitle;
    private int mImgPath;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_skid_right2);
        mImgBg = (ImageView) findViewById(R.id.img_bg);
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mImgGif = (ImageView) findViewById(R.id.img_gif);
        Intent intent = getIntent();
        if (intent != null) {
            mImgPath = intent.getIntExtra("img", R.mipmap.skid_right_1);
            String title = intent.getStringExtra("title");
            mTvTitle.setText(title);
            Glide.with(this).load(mImgPath).into(mImgBg);
            new Handler().postDelayed(() -> Glide.with(SkidRight2Activity.this).asGif().load(mImgPath).into(mImgGif), 1000);
        }
    }

    @Override
    public void onBackPressed() {
        mImgGif.setVisibility(View.INVISIBLE);
        super.onBackPressed();
    }
}
